package cn.fl.spl.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.upload.constant.SysUlFilesRecConstant;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.constant.BaseExceptionConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.logger.eum.LogOperEnum;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.cmm.cache.framework.utils.PropertiesCacheUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.product.service.ISplInfoService;
import cn.fl.product.vo.SplInfoVO;
import cn.fl.spl.service.ISplRankInfoService;
import cn.fl.spl.service.ISplStoreInfoService;
import cn.fl.spl.service.IStoreStatsDataService;
import cn.fl.spl.utils.FileUtil;
import cn.fl.spl.vo.SplRankInfoVO;
import cn.fl.spl.vo.SplStoreInfoVO;
import cn.fl.spl.vo.StoreStatsDataVO;
import cn.fl.system.constant.SysLogConstant;
import cn.lb.framework.poi.excel.ExcelExportUtil;
import cn.lb.framework.poi.excel.entity.ExportParams;
import cn.lb.framework.poi.excel.entity.TemplateExportParams;
import cn.lb.framework.poi.excel.entity.enmus.ExcelStyleType;
import cn.lb.framework.poi.excel.entity.enmus.ExcelType;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import fl.constant.facade.framework.constant.BusinessIdConstant;
import fl.mongo.facade.analysis.condition.SplRankInfoCondition;
import fl.mongo.facade.analysis.condition.StoreStatsDataCondition;
import fl.mongo.facade.base.page.PaginationVo;
import fl.mongo.facade.framework.enums.analysis.SplRankTypeEnum;
import fl.mongo.facade.framework.enums.analysis.StoreLiveTypCdNum;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.framework.enums.SplBscInfoConstant;
import fl.spl.facade.store.condition.SplStoreInfoQueryCondition;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Created by jiangzhongge on 2018-3-2.
 * Time 11:58.
 * Class belongs to fl-ass-service.
 */
@Controller
@RequestMapping(value = "/mongo/storeStats")
public class StoreStatsDataController extends BaseController {

    @Autowired
    private IStoreStatsDataService storeStatsDataService;

    @Autowired
    private ISplInfoService splInfoService;

    @Autowired
    private ISplRankInfoService splRankInfoService;

    @Autowired
    private ISysDictionaryApiService sysDictionaryApiService;

    @Autowired
    private ISplStoreInfoService splStoreInfoService;

    @RequestMapping(value = "/addStoreStatsDataInfo.do", method = {RequestMethod.GET, RequestMethod.POST})
    public void addStoreStatsDataInfo(HttpServletRequest request, HttpServletResponse response) {
        DataResultVO dataResultVO = new DataResultVO(BaseConstant.IS_YESNO_YES, "success");
        StoreStatsDataVO entity = null;
        response.setContentType("text/plain");
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        response.setHeader("Access-Control-Allow-Origin", "*");
        PrintWriter out = null;
        try {
            out = response.getWriter();
        } catch (IOException e) {
            e.printStackTrace();
        }
        String jsonString = null ;
        try {
            entity = this.comboParamsForStoreStatsData(request);//获取参数
            if (null == entity) {
                dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
                dataResultVO.setInfo("请求参数不完整");
                jsonString = JSON.toJSONString(dataResultVO);
                out.println(jsonString);
                out.flush();
                out.close();
                return ;
            }
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(new Date());
            if(StringUtils.isNotEmpty(entity.getLiveType()) && StoreLiveTypCdNum.WELCOME.name().equalsIgnoreCase(entity.getLiveType())){
                StoreStatsDataCondition condition = this.comboConditionForSSD(request);
                if(null != condition){
                    condition.setDayOfMonth(calendar.get(Calendar.DAY_OF_MONTH));
                    condition.setDayOfWeek(calendar.get(Calendar.DAY_OF_WEEK) == 1 ? 7 : calendar.get(Calendar.DAY_OF_WEEK) - 1);
                    condition.setYear(calendar.get(Calendar.YEAR));
                    condition.setMonth(calendar.get(Calendar.MONTH) + 1);
                    condition.setWeekPd(calendar.get(Calendar.WEEK_OF_YEAR));
                    StoreStatsDataVO storeStatsDataVO = this.storeStatsDataService.getOneStoreStatsData(condition);
                    if(null != storeStatsDataVO){
                        storeStatsDataVO.setTotalNum(storeStatsDataVO.getTotalNum()+1);
                        storeStatsDataVO.setActionDt(new Date());
                        boolean flag = this.storeStatsDataService.upsertStoreStatsData(condition, entity);
                        if(flag){
                            BaseLogUtils.newWebLogger("新增AppStatsDataVO成功")
                                    .setLogOperType(LogOperEnum.REQ)
                                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                                    .setWarning(false)
                                    .info();
                        }else{
                            dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
                            dataResultVO.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + "更新数据失败");
                            BaseLogUtils.newWebLogger("新增AppStatsDataVO数据失败.DATA:" + JSONObject.toJSONString(storeStatsDataVO))
                                    .setLogOperType(LogOperEnum.REQ)
                                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                                    .setWarning(false)
                                    .warn(LogExceptionEnum.COMMON_CODE_0002);
                        }
                        jsonString = JSON.toJSONString(dataResultVO);
                        out.println(jsonString);
                        out.flush();
                        out.close();
                        return ;
                    }
                }else{
                    dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
                    dataResultVO.setInfo("请求参数不完整");
                    jsonString = JSON.toJSONString(dataResultVO);
                    out.println(jsonString);
                    out.flush();
                    out.close();
                    return ;
                }
            }
            entity.setActionDt(new Date());
            entity.setCrtTm(new Date());
            entity.setDayOfMonth(calendar.get(Calendar.DAY_OF_MONTH));
            entity.setDayOfWeek(calendar.get(Calendar.DAY_OF_WEEK) == 1 ? 7 : calendar.get(Calendar.DAY_OF_WEEK) - 1);
            entity.setYear(calendar.get(Calendar.YEAR));
            entity.setMonth(calendar.get(Calendar.MONTH) + 1);
            entity.setWeekPd(calendar.get(Calendar.WEEK_OF_YEAR));
            entity.setTotalNum(1L);
            this.storeStatsDataService.insertStoreStatsData(entity);
            BaseLogUtils.newWebLogger("新增StoreStatsDataVO数据成功.DATA:" + JSONObject.toJSONString(entity))
                    .setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
        } catch (BaseException ex) {
            dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
            dataResultVO.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.newWebLogger("新增StoreStatsDataVO数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
        } catch (Exception ex) {
            dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
            dataResultVO.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR + ex.getMessage());
            BaseLogUtils.newWebLogger("新增StoreStatsDataVO数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(ex)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
        }
        jsonString = JSON.toJSONString(dataResultVO);
        out.println(jsonString);
        out.flush();
        out.close();
    }

    /**
     * 获取供应商销售区域数据字典
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/getSplSaleAreaInfo.do", method = {RequestMethod.GET, RequestMethod.POST})
    public void getSplSaleAreaInfo(HttpServletRequest request, HttpServletResponse response) {
        DataResultVO dataResultVO = new DataResultVO(BaseConstant.IS_YESNO_YES, "success");
        response.setContentType("text/plain");
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        response.setHeader("Access-Control-Allow-Origin", "*");
        PrintWriter out = null;
        try {
            out = response.getWriter();
        } catch (IOException e) {
            e.printStackTrace();
        }
        String jsonStr = null ;
        List<KeyValueVO> keyValueVOs = this.sysDictionaryApiService.getKvList(SplBscInfoConstant.SPL_SALE_AREA_TYP_CD, SplSystemConstant.SPL_SYS_CD, SplSystemConstant.DEFAULT_ORG_CD);
        if (CollectionUtils.isEmpty(keyValueVOs)) {
            dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
            dataResultVO.setInfo("failure");
            jsonStr = JSON.toJSONString(dataResultVO);
            out.println(jsonStr);
            out.flush();
            out.close();
            return ;
        }
        JSONObject jsonObject = new JSONObject();
        for (KeyValueVO vo : keyValueVOs) {
            jsonObject.put(vo.getKey(), vo.getValue());
        }
        dataResultVO.setData(jsonObject);
        jsonStr = JSON.toJSONString(dataResultVO);
        out.println(jsonStr);
        out.flush();
        out.close();
    }

    /**
     * App,H5 风云榜
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/getSplRankList.do", method = {RequestMethod.GET, RequestMethod.POST})
    public void getSplRankList(HttpServletRequest request, HttpServletResponse response) {
        DataResultVO dataResultVO = new DataResultVO(BaseConstant.IS_YESNO_YES, "success");
        response.setContentType("text/plain");
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        response.setHeader("Access-Control-Allow-Origin", "*");
        PrintWriter out = null;
        try {
            out = response.getWriter();
        } catch (IOException e) {
            e.printStackTrace();
        }
        String jsonStr = null ;
        String splId = request.getParameter("splId");
        //非必填项
        String storeId = request.getParameter("storeId");
        //非必填项
        String type = request.getParameter("type");
        //区域（"1":"本市","2":"本省","3":"全国"）
        //必填，期数
        String period = request.getParameter("period");
        //非必填，风云榜版本，上半月为V1，下半月为V2
        String rankVersion = request.getParameter("rankVersion");
        //省市code
        String code = request.getParameter("code");
        //请求类型
        String reqType = request.getParameter("reqType");
        //年份
        String year = request.getParameter("year");
        //月份
        String month = request.getParameter("month");
        SplRankInfoCondition condition = null;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        int currentDay = calendar.get(Calendar.DAY_OF_MONTH);
        int currentMonth = calendar.get(Calendar.MONTH)+1;
        int currentYear = calendar.get(Calendar.YEAR);
        if (StringUtils.isNotEmpty(reqType) && "share".equalsIgnoreCase(reqType)) { //先判断是否有期数
            if (StringUtils.isEmpty(type) || StringUtils.isEmpty(period) ||
                    StringUtils.isEmpty(rankVersion) || StringUtils.isEmpty(code)) {
                dataResultVO.setInfo("有参数为空，请核实参数！");
                dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
                jsonStr = JSON.toJSONString(dataResultVO);
                out.println(jsonStr);
                out.flush();
                out.close();
                return ;
            }
            condition = new SplRankInfoCondition();
            condition.setCode(code);
            condition.setPeriod(period);
            condition.setType(type);
            condition.setRankVersion(rankVersion);
            condition.setMonth(StringUtils.isNotEmpty(month) ? Integer.valueOf(month) : Integer.valueOf(period));
            condition.setYear(StringUtils.isNotEmpty(year) ? Integer.valueOf(year) : currentYear);
        } else {
            if (StringUtils.isEmpty(type)) {
                dataResultVO.setInfo("有参数为空，请核实参数！");
                dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
                jsonStr = JSON.toJSONString(dataResultVO);
                out.println(jsonStr);
                out.flush();
                out.close();
                return ;
            } else {
                if (!SplRankTypeEnum.NATIONAL.getDesc().equals(type) && StringUtils.isEmpty(splId)) {
                    dataResultVO.setInfo("通过一级认证之后，才可查询省市供应商排行榜");
                    dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
                    jsonStr = JSON.toJSONString(dataResultVO);
                    out.println(jsonStr);
                    out.flush();
                    out.close();
                    return ;
                }
            }
            condition = new SplRankInfoCondition();
            condition.setType(type);
            if (StringUtils.isEmpty(period)) {
                period = String.valueOf(currentMonth);
            }
            condition.setPeriod(period);
            if (StringUtils.isEmpty(rankVersion)) {
                if (currentDay > 15) {
                    rankVersion = "V2";
                } else {
                    rankVersion = "V1";
                }
            }
            condition.setRankVersion(rankVersion);
            condition.setYear(currentYear);
            condition.setMonth(currentMonth);
            if (StringUtils.isNotEmpty(splId)) {
                SplInfoVO splInfoVO = this.splInfoService.selectById(Long.valueOf(splId));
                if (null != splInfoVO) {
                    if (SplRankTypeEnum.CITY.getDesc().equals(type)) {
                        code = splInfoVO.getRgnCyCd();
                    } else if (SplRankTypeEnum.PROVINCE.getDesc().equals(type)) {
                        code = splInfoVO.getRgnPrCd();
                    } else {
                        code = "nation";
                    }
                    condition.setCode(code);
                } else {
                    condition.setCode("nation");
                }
            } else {
                condition.setCode("nation");
            }
        }
        if (null != condition) {
            List<SplRankInfoVO> splRankInfoVOs = this.splRankInfoService.getSplRankInfoList(condition);
            if (CollectionUtils.isNotEmpty(splRankInfoVOs) && ("share").equals(reqType)) {
                List<Long> splIds = new ArrayList<>(splRankInfoVOs.size());
                Collections.sort(splRankInfoVOs, comparator);
                if(splRankInfoVOs.size() > 10){
                    for (int i=0;i<10;i++) {
                        splIds.add(Long.valueOf(splRankInfoVOs.get(i).getSplId()));
                    }
                }else{
                    for (SplRankInfoVO vo : splRankInfoVOs) {
                        splIds.add(Long.valueOf(vo.getSplId()));
                    }
                }
                SplStoreInfoQueryCondition storeInfoQueryCondition = new SplStoreInfoQueryCondition();
                storeInfoQueryCondition.setSplIdList(splIds);
                List<SplStoreInfoVO> storeList = this.splStoreInfoService.searchListByCondition(storeInfoQueryCondition);
                if (CollectionUtils.isEmpty(storeList)) {
                    dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
                    dataResultVO.setInfo("查询中，请稍后再试！");
                    jsonStr = JSON.toJSONString(dataResultVO);
                    out.println(jsonStr);
                    out.flush();
                    out.close();
                    return ;
                }
                Map<Long, SplStoreInfoVO> storeIdMap = new HashMap(storeList.size());
                for (SplStoreInfoVO store : storeList) {
                    storeIdMap.put(store.getId(), store);
                }
                for (SplRankInfoVO vo : splRankInfoVOs) {
                    if (SplRankTypeEnum.NATIONAL.getDesc().equals(vo.getType())) {
                        vo.setCodeNm("全国");
                    }
                    if (CollectionUtils.isMapNotEmpty(storeIdMap) && storeIdMap.containsKey(vo.getStoreId())) {
                        vo.setConTel(StringUtils.isNotEmpty(storeIdMap.get(vo.getStoreId()).getContTel()) ? storeIdMap.get(vo.getStoreId()).getContTel() : "");
                        vo.setStoreAddr(StringUtils.isNotEmpty(storeIdMap.get(vo.getStoreId()).getStoreAddress()) ? storeIdMap.get(vo.getStoreId()).getStoreAddress() : "");
                    }
                }
            }
            BaseLogUtils.newWebLogger("排行榜数据SORT前，DATA:" + JSONObject.toJSONString(splRankInfoVOs))
                    .setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            dataResultVO.setData(splRankInfoVOs);
            BaseLogUtils.newWebLogger("排行榜数据SORT后，DATA:" + JSONObject.toJSONString(dataResultVO))
                    .setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            jsonStr = JSON.toJSONString(dataResultVO);
            out.println(jsonStr);
            out.flush();
            out.close();
            return ;
        } else {
            dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
            dataResultVO.setInfo("查询中，请稍后再试！");

            jsonStr = JSON.toJSONString(dataResultVO);
            out.println(jsonStr);
            out.flush();
            out.close();
            return ;
        }
    }

    Comparator<SplRankInfoVO> comparator = new Comparator<SplRankInfoVO>() {
        @Override
        public int compare(SplRankInfoVO o1, SplRankInfoVO o2) {
            if(o1.getRankNo().compareTo(o2.getRankNo()) > 0){
                return 1;
            }else if(o1.getRankNo().equals(o2.getRankNo())){
                if(o1.getId().compareTo(o2.getId()) > 0){
                    return 1 ;
                }else{
                    return -1 ;
                }
            }else{
                return -1 ;
            }
        }
    };

    /**
     * App,H5 风云榜
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/getSplRankShareParams.do", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public Object getSplRankShareParams(HttpServletRequest request, HttpServletResponse response) {
        DataResultVO dataResultVO = new DataResultVO(BaseConstant.IS_YESNO_YES, "success");

        String splId = request.getParameter("splId");
        //非必填项
        String storeId = request.getParameter("storeId");
        //非必填项
        String type = request.getParameter("type");
        //必填区域（"1":"本市","2":"本省","3":"全国"）
        String usrId = request.getParameter("usrId");
        //必填当前用户ID
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        int currentDay = calendar.get(Calendar.DAY_OF_MONTH);
        int currentMonth = calendar.get(Calendar.MONTH) + 1;
        int currentYear = calendar.get(Calendar.YEAR);
        String urlPath = null ; //PropertiesCacheUtils.getProperty(WebBaseConstant.H5_URL_PATH);
        String urlRoute = null ; //PropertiesCacheUtils.getProperty(WebBaseConstant.H5_URL_SPL_RANK_ROUTE);
        StringBuffer reqUrl = null;
        StringBuffer shareUrl = null;
        StringBuffer title = new StringBuffer("狮桥风云榜");
        if(StringUtils.isNotEmpty(urlPath) && StringUtils.isNotEmpty(urlRoute)){
            reqUrl = new StringBuffer(urlPath).append(urlRoute);
            shareUrl = new StringBuffer(urlPath).append(urlRoute);
        }else{
            reqUrl = new StringBuffer("http://10.10.23.57:8080/#/Billboard");
            shareUrl = new StringBuffer("http://10.10.23.57:8080/#/Billboard");
        }
        if (StringUtils.isEmpty(type)) {
            dataResultVO.setInfo("有参数为空，请核实参数！");
            dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
            return dataResultVO;
        } else {
            if (StringUtils.isEmpty(splId)) {
                if(!"3".equals(type)){
                    dataResultVO.setSuccess(BaseConstant.IS_YESNO_NO);
                    dataResultVO.setInfo("请先注册供应商信息，再来查询！");
                    return dataResultVO;
                }

                dataResultVO.setInfo("通过一级认证之后，才可查询省市供应商排行榜");
                String rankVersion = "V1";
                StringBuffer beginDt = new StringBuffer();
                StringBuffer endDt = new StringBuffer();
                if (currentDay > 15) {
                    beginDt.append(currentYear).append("/").append(currentMonth).append("/").append("1");
                    endDt.append(currentYear).append("/").append(currentMonth).append("/").append("15");
                    rankVersion = "V2";
                }else{
                    if(1 == currentMonth){
                        beginDt.append(currentYear -1).append("/").append(12).append("/").append("16");
                        endDt.append(currentYear-1).append("/").append(12).append("/").append("31");
                    }else if(3 == currentMonth){
                        beginDt.append(currentYear).append("/").append(2).append("/").append("16");
                        if(0 == (currentYear % 4)){
                            endDt.append(currentYear).append("/").append(2).append("/").append("29");
                        }else{
                            endDt.append(currentYear).append("/").append(2).append("/").append("28");
                        }
                    }else{
                        calendar.clear();
                        calendar.set(Calendar.YEAR,currentYear);
                        calendar.set(Calendar.MONTH, currentMonth - 1);
                        int days =calendar.getActualMaximum(Calendar.DATE);//本月份的天数
                        beginDt.append(currentYear).append("/").append(currentMonth).append("/").append("16");
                        endDt.append(currentYear).append("/").append(currentMonth).append("/").append(days);
                    }
                }
                title.append("(").append(beginDt).append("~").append(endDt).append(")");
                JSONObject object = new JSONObject();
                //TODO 文案
                object.put("title", title);
                object.put("content", "");
                object.put("imgUrl", "");
                reqUrl.append("?").append("splId= ").append("&storeId= ").append("&type=").append(type).append("&inapp=1").append("&fstUsrId=").append(usrId);
                shareUrl.append("?").append("splId= ").append("&storeId= ").append("&type=").append(type).append("&inapp=0");
                shareUrl.append("&month=").append(currentMonth).append("&year=").append(currentYear).append("&rankVersion=").append(rankVersion).append("&fstUsrId=").append(usrId);
                shareUrl.append("&period=").append(String.valueOf(currentMonth)).append("&reqType=").append("share").append("&code=").append("nation");
                try {
                    object.put("reqUrl", new URL(reqUrl.toString()));
                } catch (MalformedURLException e) {
                    e.printStackTrace();
                }
                object.put("shareUrl",shareUrl.toString());
                dataResultVO.setData(object);
                return dataResultVO;
            }
        }
        SplInfoVO splInfoVO = this.splInfoService.selectById(Long.valueOf(splId));
        String code = null;
        if (null != splInfoVO) {
            if (SplRankTypeEnum.CITY.getDesc().equals(type)) {
                code = splInfoVO.getRgnPrCd();
            } else if (SplRankTypeEnum.PROVINCE.getDesc().equals(type)) {
                code = splInfoVO.getRgnPrCd();
            } else {
                code = "nation";
            }
        } else {
            code = "nation";
        }
        JSONObject object = new JSONObject();
        String rankVersion = "V1";
        StringBuffer beginDt = new StringBuffer();
        StringBuffer endDt = new StringBuffer();
        if (currentDay > 15) {
            beginDt.append(currentYear).append("/").append(currentMonth).append("/").append("1");
            endDt.append(currentYear).append("/").append(currentMonth).append("/").append("15");
            rankVersion = "V2";
        }else{
            if(1 == currentMonth){
                beginDt.append(currentYear -1).append("/").append(12).append("/").append("16");
                endDt.append(currentYear-1).append("/").append(12).append("/").append("31");
            }else if(3 == currentMonth){
                beginDt.append(currentYear).append("/").append(2).append("/").append("16");
                if(0 == (currentYear % 4)){
                    endDt.append(currentYear).append("/").append(2).append("/").append("29");
                }else{
                    endDt.append(currentYear).append("/").append(2).append("/").append("28");
                }
            }else{
                calendar.clear();
                calendar.set(Calendar.YEAR,currentYear);
                calendar.set(Calendar.MONTH, currentMonth - 1);
                int days =calendar.getActualMaximum(Calendar.DATE);//本月份的天数
                beginDt.append(currentYear).append("/").append(currentMonth).append("/").append("16");
                endDt.append(currentYear).append("/").append(currentMonth).append("/").append(days);
            }
        }
        title.append("(").append(beginDt).append("~").append(endDt).append(")");
        //TODO 文案
        object.put("title",title.toString());
        object.put("content", "");
        object.put("imgUrl", "");
        reqUrl.append("?").append("splId=").append(splId).append("&storeId= ").append("&type=").append(type).append("&fstUsrId=").append(usrId);
        reqUrl.append("&code=").append(code).append("&inapp=1");
        shareUrl.append("?").append("splId=").append(splId).append("&storeId= ").append("&type=").append(type).append("&code=").append(code).append("&inapp=1");
        shareUrl.append("&month=").append(currentMonth).append("&year=").append(currentYear).append("&rankVersion=").append(rankVersion);
        shareUrl.append("&period=").append(String.valueOf(currentMonth)).append("&reqType=").append("share").append("&fstUsrId=").append(usrId);
        try {
            object.put("reqUrl", new URL(reqUrl.toString()));
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        object.put("shareUrl",shareUrl.toString());
        dataResultVO.setData(object);
        return dataResultVO;
    }

    /**
     * 获取供应商数据统计信息
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/getStoreStatsDataInfo.do",method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public DataResultVO getAppStatsDataInfo(HttpServletRequest request, HttpServletResponse response){

        DataResultVO dataResultVO = new DataResultVO(BaseConstant.IS_YESNO_YES,String.valueOf(BaseConstant.IS_YESNO_YES));
        String dayRegion = request.getParameter("dayRegion");
        String dateMin = request.getParameter("dateMin");
        String dateMax = request.getParameter("dateMax");
        String splNm = request.getParameter("splNm");
        String splId = request.getParameter("splId");

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());

        StoreStatsDataCondition condition = new StoreStatsDataCondition();
        condition.setSysCd(SplSystemConstant.SPL_SHOP_APP_CD);

        if(StringUtils.isNotEmpty(splId)){
            condition.setSplId(Long.valueOf(splId));
        }
        if(StringUtils.isNotEmpty(dayRegion)){
            if("1".equals(dayRegion)){
                calendar.add(Calendar.DAY_OF_MONTH, -1);
            }else if("7".equals(dayRegion)){
                calendar.add(Calendar.DAY_OF_MONTH, -7);
            }else if("15".equals(dayRegion)){
                calendar.add(Calendar.DAY_OF_MONTH, -15);
            }else if("30".equals(dayRegion)){
                calendar.add(Calendar.DAY_OF_MONTH, -30);
            }
            condition.setCrtTmMin(calendar.getTime());
            condition.setCrtTmMax(new Date());
        }else{
            if(StringUtils.isEmpty(dateMin) && StringUtils.isEmpty(dateMax)){
                calendar.add(Calendar.DAY_OF_MONTH,-1);
                condition.setCrtTmMin(calendar.getTime());
                condition.setCrtTmMax(new Date());
            }
        }

        if(StringUtils.isEmpty(dayRegion) && (StringUtils.isNotEmpty(dateMin) || StringUtils.isNotBlank(dateMax))){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            try{
                if(StringUtils.isNotEmpty(dateMin)){
                    if(StringUtils.isNotEmpty(dateMax)){
                        dateMin = dateMin+" 00:00:00";
                        dateMax = dateMax+" 00:00:00";
                        condition.setCrtTmMin(sdf.parse(dateMin));
                        condition.setCrtTmMax(sdf.parse(dateMax));
                    }else{
                        dateMin = dateMin+" 00:00:00";
                        condition.setCrtTmMin(sdf.parse(dateMin));
                        condition.setCrtTmMax(new Date());
                    }
                }else{
                    if(StringUtils.isNotEmpty(dateMax)){
                        dateMax = dateMax+" 00:00:00";
                        condition.setCrtTmMax(sdf.parse(dateMax));
                    }
                }
            }catch (ParseException pe){
                BaseLogUtils.newWebLogger("时间数据类型转换异常,业务异常").setLogOperType(LogOperEnum.REQ)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                        .setWarning(false)
                        .setThrowable(pe)
                        .warn(LogExceptionEnum.COMMON_CODE_0002);
                pe.printStackTrace();
            }
        }

        // 文章类
        condition.setType("0");
        condition.setLiveType(StoreLiveTypCdNum.BROWSE.name());
        Long articleBrowseCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);
        condition.setLiveType(StoreLiveTypCdNum.SHARE.name());
        Long articleShareCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);
        condition.setLiveType(StoreLiveTypCdNum.CONSULT.name());
        Long articleConsultCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);

        //店铺类
        condition.setType("1");
        condition.setLiveType(StoreLiveTypCdNum.BROWSE.name());
        Long storeBrowseCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);
        condition.setLiveType(StoreLiveTypCdNum.SHARE.name());
        Long storeShareCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);
        condition.setLiveType(StoreLiveTypCdNum.CONSULT.name());
        Long storeConsultCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);

        JSONObject analyData = new JSONObject();
        analyData.put("articleBrowseCount", articleBrowseCount == null ? 0 : articleBrowseCount);
        analyData.put("articleShareCount", articleShareCount == null ? 0 : articleShareCount);
        analyData.put("articleConsultCount", articleConsultCount == null ? 0 : articleConsultCount);
        analyData.put("storeBrowseCount", storeBrowseCount == null ? 0 : storeBrowseCount);
        analyData.put("storeShareCount", storeShareCount == null ? 0 : storeShareCount);
        analyData.put("storeConsultCount", storeConsultCount == null ? 0 : storeConsultCount);

        dataResultVO.setData(analyData);

        return dataResultVO;
    }

    /**
     * 导出数据统计信息
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/exportStoreStatsDataList.do",method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public DataResultVO exportStoreStatsDataList(HttpServletRequest request, HttpServletResponse response){

        DataResultVO dataResultVO = new DataResultVO(BaseConstant.IS_YESNO_YES,String.valueOf(BaseConstant.IS_YESNO_YES));
        String dayRegion = request.getParameter("dayRegion");
        String dateMin = request.getParameter("dateMin");
        String dateMax = request.getParameter("dateMax");
        String splNm = request.getParameter("splNm");
        String splId = request.getParameter("splId");

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());

        StoreStatsDataCondition condition = new StoreStatsDataCondition();
        condition.setSysCd(SplSystemConstant.SPL_SHOP_APP_CD);

        if(StringUtils.isNotEmpty(splId)){
            condition.setSplId(Long.valueOf(splId));
        }
        if(StringUtils.isNotEmpty(dayRegion)){
            if("1".equals(dayRegion)){
                calendar.add(Calendar.DAY_OF_MONTH, -1);
            }else if("7".equals(dayRegion)){
                calendar.add(Calendar.DAY_OF_MONTH, -7);
            }else if("15".equals(dayRegion)){
                calendar.add(Calendar.DAY_OF_MONTH, -15);
            }else if("30".equals(dayRegion)){
                calendar.add(Calendar.DAY_OF_MONTH, -30);
            }
            condition.setCrtTmMin(calendar.getTime());
            condition.setCrtTmMax(new Date());
        }else{
            if(StringUtils.isEmpty(dateMin) && StringUtils.isEmpty(dateMax)){
                calendar.add(Calendar.DAY_OF_MONTH,-1);
                condition.setCrtTmMin(calendar.getTime());
                condition.setCrtTmMax(new Date());
            }
        }

        if(StringUtils.isEmpty(dayRegion) && (StringUtils.isNotEmpty(dateMin) || StringUtils.isNotBlank(dateMax))){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            try{
                if(StringUtils.isNotEmpty(dateMin)){
                    if(StringUtils.isNotEmpty(dateMax)){
                        dateMin = dateMin+" 00:00:00";
                        dateMax = dateMax+" 00:00:00";
                        condition.setCrtTmMin(sdf.parse(dateMin));
                        condition.setCrtTmMax(sdf.parse(dateMax));
                    }else{
                        dateMin = dateMin+" 00:00:00";
                        condition.setCrtTmMin(sdf.parse(dateMin));
                        condition.setCrtTmMax(new Date());
                    }
                }else{
                    if(StringUtils.isNotEmpty(dateMax)){
                        dateMax = dateMax+" 00:00:00";
                        condition.setCrtTmMax(sdf.parse(dateMax));
                    }
                }
            }catch (ParseException pe){
                BaseLogUtils.newWebLogger("时间数据类型转换异常,业务异常").setLogOperType(LogOperEnum.REQ)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                        .setWarning(false)
                        .setThrowable(pe)
                        .warn(LogExceptionEnum.COMMON_CODE_0002);
                pe.printStackTrace();
            }
        }

        // 文章类
        condition.setType("0");
        condition.setLiveType(StoreLiveTypCdNum.BROWSE.name());
        Long articleBrowseCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);
        condition.setLiveType(StoreLiveTypCdNum.SHARE.name());
        Long articleShareCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);
        condition.setLiveType(StoreLiveTypCdNum.CONSULT.name());
        Long articleConsultCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);

        //店铺类
        condition.setType("1");
        condition.setLiveType(StoreLiveTypCdNum.BROWSE.name());
        Long storeBrowseCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);
        condition.setLiveType(StoreLiveTypCdNum.SHARE.name());
        Long storeShareCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);
        condition.setLiveType(StoreLiveTypCdNum.CONSULT.name());
        Long storeConsultCount = this.storeStatsDataService.statisStoreStatsDataCount(condition);


        JSONObject analyData = new JSONObject();
        analyData.put("articleBrowseCount", articleBrowseCount == null ? 0 : articleBrowseCount);
        analyData.put("articleShareCount", articleShareCount == null ? 0 : articleShareCount);
        analyData.put("articleConsultCount", articleConsultCount == null ? 0 : articleConsultCount);
        analyData.put("storeBrowseCount", storeBrowseCount == null ? 0 : storeBrowseCount);
        analyData.put("storeShareCount", storeShareCount == null ? 0 : storeShareCount);
        analyData.put("storeConsultCount", storeConsultCount == null ? 0 : storeConsultCount);

        //导出数据
        Map<String, Object> map = new HashMap<String, Object>();
        FileOutputStream fos = null;
        map.put("articleBrowseCount", articleBrowseCount == null ? 0 : articleBrowseCount);
        map.put("articleShareCount", articleShareCount == null ? 0 : articleShareCount);
        map.put("articleConsultCount", articleConsultCount == null ? 0 : articleConsultCount);
        map.put("storeBrowseCount", storeBrowseCount == null ? 0 : storeBrowseCount);
        map.put("storeShareCount", storeShareCount == null ? 0 : storeShareCount);
        map.put("storeConsultCount", storeConsultCount == null ? 0 : storeConsultCount);

        String tempPath = "template/spl/storeStatsData/storeStatsData.xlsx";

        TemplateExportParams params = new TemplateExportParams(tempPath, false, "数据统计");
        params.setHeadingRows(0);
        params.setHeadingStartRow(1);
        params.setStyle(ExcelStyleType.BORDER.getClazz());
        params.setColForEach(true);//注：包含遍历list
        //文件保存路径
        String filePath = "analysis/";
        String serverFilePath = FileUtil.getServerFilePath(filePath);
        serverFilePath = serverFilePath + "STOREANLAY" + System.currentTimeMillis() + ".xlsx";

        try {
            Workbook book = ExcelExportUtil.exportExcel(params, map);
            fos = new FileOutputStream(serverFilePath);
            book.write(fos);
            fos.flush();
        } catch (FileNotFoundException e) {
            BaseLogUtils.newWebLogger("导出统计数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_700, e.getMessage());
        } catch (IOException e) {
            BaseLogUtils.newWebLogger("导出统计数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_700, e.getMessage());
        } catch (Exception e) {
            BaseLogUtils.newWebLogger("导出统计数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_700, e.getMessage());
        } finally {
            try {
                if (null != fos) {
                    fos.close();
                }
            } catch (IOException e) {
                BaseLogUtils.newWebLogger("IOException").setLogOperType(LogOperEnum.REQ)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                        .setWarning(false)
                        .setThrowable(e)
                        .warn(LogExceptionEnum.COMMON_CODE_0002);
            }
        }
        serverFilePath = serverFilePath.replace(PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_ROOT_PATH),
                PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_SERVER_PATH));
        BaseLogUtils.newWebLogger("导出统计数据,返回服务器路径.serverPath:" + serverFilePath).setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();

        dataResultVO.setSuccess(BaseConstant.IS_YESNO_YES);
        dataResultVO.setInfo("导出统计数据成功");
        dataResultVO.setData(serverFilePath);

        return dataResultVO;
    }

    /**
     * 导出数据统计信息
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/exportStoreStatsDataListBk.do",method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    public DataResultVO exportStoreStatsDataListBk(HttpServletRequest request, HttpServletResponse response){

        DataResultVO dataResultVO = new DataResultVO(BaseConstant.IS_YESNO_YES,String.valueOf(BaseConstant.IS_YESNO_YES));
        String dayRegion = request.getParameter("dayRegion");
        String dateMin = request.getParameter("dateMin");
        String dateMax = request.getParameter("dateMax");
        String splNm = request.getParameter("splNm");
        String splId = request.getParameter("splId");

        StoreStatsDataCondition condition = new StoreStatsDataCondition();
        condition.setSysCd(SplSystemConstant.SPL_SHOP_APP_CD);

        if(StringUtils.isNotEmpty(splId)){
            condition.setSplId(Long.valueOf(splId));
        }

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        Calendar calendarLast = Calendar.getInstance();
        calendarLast.setTime(new Date());
        String formatStr = "yyyy-MM-dd HH:mm:ss";
        if(StringUtils.isNotEmpty(dateMin) || StringUtils.isNotEmpty(dateMax)){
            //按时间段查询
            try {
                if (StringUtils.isNotEmpty(dateMin)) {
                    if (StringUtils.isNotEmpty(dateMax)) {
                        dateMin = dateMin + " 00:00:00";
                        dateMax = dateMax + " 00:00:00";
                        if(compareDate(dateMin, DateUtils.formatDateToString(calendar.getTime(), formatStr),formatStr) == 1){
                            if(compareDate(dateMax,DateUtils.formatDateToString(calendar.getTime(),formatStr),formatStr) == 1){
                                calendar.setTime(DateUtils.formatStringToDate(dateMax,formatStr));
                                calendarLast.setTime(DateUtils.formatStringToDate(dateMin,formatStr));
                            }else{
                                calendarLast.setTime(DateUtils.formatStringToDate(dateMin,formatStr));
                            }
                        }
                    } else {
                        dateMin = dateMin + " 00:00:00";
                        if(compareDate(dateMin,DateUtils.formatDateToString(calendar.getTime(),formatStr),formatStr) == 1){
                            calendarLast.setTime(DateUtils.formatStringToDate(dateMin,formatStr));
                        }
                    }
                } else {
                    if (StringUtils.isNotEmpty(dateMax)) {
                        dateMax = dateMax + " 00:00:00";
                        if(compareDate(dateMax,DateUtils.formatDateToString(calendar.getTime(),formatStr),formatStr) == 1){
                            calendar.setTime(DateUtils.formatStringToDate(dateMax,formatStr));
                            calendarLast.setTime(DateUtils.formatStringToDate(dateMax,formatStr));
                            calendarLast.add(Calendar.DAY_OF_MONTH, -1);
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }else{
            if(StringUtils.isNotEmpty(dayRegion)){
                //按天数范围查询
                if ("1".equals(dayRegion)) {
                    calendarLast.add(Calendar.DAY_OF_MONTH, -1);
                } else if ("7".equals(dayRegion)) {
                    calendarLast.add(Calendar.DAY_OF_MONTH, -7);
                } else if ("15".equals(dayRegion)) {
                    calendarLast.add(Calendar.DAY_OF_MONTH, -15);
                } else if ("30".equals(dayRegion)) {
                    calendarLast.add(Calendar.DAY_OF_MONTH, -30);
                }
            }else{
                //查询昨天的数据
                calendarLast.add(Calendar.DAY_OF_MONTH, -1);
            }
        }
        //时间段内天数之差
        Long days = DateUtils.getDaysBetweenTwoDates(calendarLast.getTime(),calendar.getTime());

        //获取导出记录
        List<Map<String,Object>> analysisDataList = getAnalysisDataList(condition,days,calendarLast,calendar);

        Map<String,Object> exportMap = new HashMap<>();
        exportMap.put("maplist", analysisDataList);
        exportMap.put("exportTm", DateUtils.formatDateToString(new Date(),"yyyy-MM-dd"));

        //导出数据
        FileOutputStream fos = null;
        String tempPath = "template/spl/storeStatsData/storeStatsData.xlsx";

        TemplateExportParams params = new TemplateExportParams(tempPath, false, "数据统计");
        params.setHeadingRows(0);
        params.setHeadingStartRow(1);
        params.setStyle(ExcelStyleType.BORDER.getClazz());
        params.setColForEach(true);//注：包含遍历list
        //文件保存路径
        String filePath = "analysis/";
        String serverFilePath = FileUtil.getServerFilePath(filePath);
        serverFilePath = serverFilePath + "STOREANLAY" + System.currentTimeMillis() + ".xlsx";
        BaseLogUtils.newWebLogger("导出统计数据文件路径=" + serverFilePath).setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();
        try {
            Workbook book = ExcelExportUtil.exportExcel(params, exportMap);
            fos = new FileOutputStream(serverFilePath);
            book.write(fos);
            fos.flush();
        } catch (FileNotFoundException e) {
            BaseLogUtils.newWebLogger("导出统计数据失败,FileNotFoundException").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_700, e.getMessage());
        } catch (IOException e) {
            BaseLogUtils.newWebLogger("修改对象失败,IOException").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_700, e.getMessage());
        } catch (Exception e) {
            BaseLogUtils.newWebLogger("导出统计数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
            throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_700, e.getMessage());
        }finally {
            try {
                if (null != fos) {
                    fos.close();
                }
            } catch (IOException e) {
                BaseLogUtils.newWebLogger("系统异常").setLogOperType(LogOperEnum.REQ)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                        .setWarning(false)
                        .setThrowable(e)
                        .error(LogExceptionEnum.COMMON_CODE_0099);
            }
        }
        serverFilePath = serverFilePath.replace(PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_ROOT_PATH),
                PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_SERVER_PATH));
        BaseLogUtils.newWebLogger("导出统计数据,返回服务器路径.serverPath:" + serverFilePath).setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();

        dataResultVO.setSuccess(BaseConstant.IS_YESNO_YES);
        dataResultVO.setInfo("导出统计数据成功");
        dataResultVO.setData(serverFilePath);

        return dataResultVO;
    }

    private StoreStatsDataVO comboParamsForStoreStatsData(HttpServletRequest request) {
        String splId = request.getParameter("splId");
        String storeId = request.getParameter("storeId");
        String dataId = request.getParameter("dataId");
        String busTypCd = request.getParameter("busTypCd");
        String sysCd = request.getParameter("sysCd");
        String liveType = request.getParameter("liveType");
        String source = request.getParameter("source");
        String fstUsrId = request.getParameter("fstUsrId");
        String type = request.getParameter("type");
        StoreStatsDataVO storeStatsDataVO = new StoreStatsDataVO();
        if (StringUtils.isNotEmpty(splId)) {
            storeStatsDataVO.setSplId(Long.valueOf(splId));
        }
        if (StringUtils.isNotEmpty(storeId)) {
            storeStatsDataVO.setStoreId(Long.valueOf(storeId));
        }
        if (StringUtils.isNotEmpty(dataId)) {
            storeStatsDataVO.setDataId(Long.valueOf(dataId));
        }
        if (StringUtils.isNotEmpty(busTypCd)) {
            storeStatsDataVO.setBusTypCd(busTypCd);
        }
        if (StringUtils.isNotEmpty(sysCd)) {
            storeStatsDataVO.setSysCd(sysCd);
        }
        if (StringUtils.isNotEmpty(liveType)) {
            storeStatsDataVO.setLiveType(liveType);
        }
        if (StringUtils.isNotEmpty(source)) {
            storeStatsDataVO.setSource(source);
        }
        if (StringUtils.isNotEmpty(fstUsrId)) {
            storeStatsDataVO.setFstUsrId(Long.valueOf(fstUsrId));
        }
        if (StringUtils.isNotEmpty(type)) {
            storeStatsDataVO.setType(type);
        }
        return storeStatsDataVO;
    }

    private StoreStatsDataCondition comboConditionForSSD(HttpServletRequest request) {
        String splId = request.getParameter("splId");
        String storeId = request.getParameter("storeId");
        String dataId = request.getParameter("dataId");
        String busTypCd = request.getParameter("busTypCd");
        String sysCd = request.getParameter("sysCd");
        String liveType = request.getParameter("liveType");
        String source = request.getParameter("source");
        String fstUsrId = request.getParameter("fstUsrId");
        String type = request.getParameter("type");
        StoreStatsDataCondition condition = new StoreStatsDataCondition();
        if (StringUtils.isNotEmpty(splId)) {
            condition.setSplId(Long.valueOf(splId));
        }
        if (StringUtils.isNotEmpty(storeId)) {
            condition.setStoreId(Long.valueOf(storeId));
        }
        if (StringUtils.isNotEmpty(dataId)) {
            condition.setDataId(Long.valueOf(dataId));
        }
        if (StringUtils.isNotEmpty(busTypCd)) {
            condition.setBusTypCd(busTypCd);
        }
        if (StringUtils.isNotEmpty(sysCd)) {
            condition.setSysCd(sysCd);
        }
        if (StringUtils.isNotEmpty(liveType)) {
            condition.setLiveType(liveType);
        }
        if (StringUtils.isNotEmpty(source)) {
            condition.setSource(source);
        }
        if (StringUtils.isNotEmpty(fstUsrId)) {
            condition.setFstUsrId(Long.valueOf(fstUsrId));
        }
        if (StringUtils.isNotEmpty(type)) {
            condition.setType(type);
        }
        return condition;
    }

    private int compareDate(String date1, String date2,String formatStr) {
        SimpleDateFormat df = new SimpleDateFormat(formatStr);
        try {
            Date dt1 = df.parse(date1);
            Date dt2 = df.parse(date2);
            if (dt1.getTime() > dt2.getTime()) {
                //System.out.println("dt1 在dt2前");
                return 1;
            } else if (dt1.getTime() < dt2.getTime()) {
                //System.out.println("dt1在dt2后");
                return -1;
            } else {
                return 0;
            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return 0;
    }

    private List<Map<String,Object>> getAnalysisDataList(StoreStatsDataCondition storeCondition,
                                                         Long days,Calendar lastCalendar,Calendar calendar){
        List<Map<String,Object>> analysisDataList = new ArrayList<>();
        Calendar calendar1 = Calendar.getInstance();
        Calendar calendar2 = Calendar.getInstance();
        Calendar calendar3 = Calendar.getInstance();
        calendar2.setTime(lastCalendar.getTime());
        for(int i=1; i<=days ;i++){
            //导出数据
            Map<String, Object> map = new HashMap<String, Object>();
            calendar1.setTime(lastCalendar.getTime());
            if(i == days){
                calendar2.setTime(calendar.getTime());
            }else{
                calendar2.add(Calendar.DAY_OF_MONTH, 1);
            }
            storeCondition.setCrtTmMin(calendar1.getTime());
            storeCondition.setCrtTmMax(calendar2.getTime());

            // 文章类
            storeCondition.setType("0");
            storeCondition.setLiveType(StoreLiveTypCdNum.BROWSE.name());
            Long articleBrowseCount = this.storeStatsDataService.statisStoreStatsDataCount(storeCondition);
            storeCondition.setLiveType(StoreLiveTypCdNum.SHARE.name());
            Long articleShareCount = this.storeStatsDataService.statisStoreStatsDataCount(storeCondition);
            storeCondition.setLiveType(StoreLiveTypCdNum.CONSULT.name());
            Long articleConsultCount = this.storeStatsDataService.statisStoreStatsDataCount(storeCondition);

            //店铺类
            storeCondition.setType("1");
            storeCondition.setLiveType(StoreLiveTypCdNum.BROWSE.name());
            Long storeBrowseCount = this.storeStatsDataService.statisStoreStatsDataCount(storeCondition);
            storeCondition.setLiveType(StoreLiveTypCdNum.SHARE.name());
            Long storeShareCount = this.storeStatsDataService.statisStoreStatsDataCount(storeCondition);
            storeCondition.setLiveType(StoreLiveTypCdNum.CONSULT.name());
            Long storeConsultCount = this.storeStatsDataService.statisStoreStatsDataCount(storeCondition);


            JSONObject analyData = new JSONObject();
            analyData.put("articleBrowseCount", articleBrowseCount == null ? 0 : articleBrowseCount);
            analyData.put("articleShareCount", articleShareCount == null ? 0 : articleShareCount);
            analyData.put("articleConsultCount", articleConsultCount == null ? 0 : articleConsultCount);
            analyData.put("storeBrowseCount", storeBrowseCount == null ? 0 : storeBrowseCount);
            analyData.put("storeShareCount", storeShareCount == null ? 0 : storeShareCount);
            analyData.put("storeConsultCount", storeConsultCount == null ? 0 : storeConsultCount);

            BaseLogUtils.newWebLogger("统计数据DATA>>" + JSONObject.toJSONString(analyData)).setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .info();
            FileOutputStream fos = null;
            map.put("articleBrowseCount", articleBrowseCount == null ? 0 : articleBrowseCount);
            map.put("articleShareCount", articleShareCount == null ? 0 : articleShareCount);
            map.put("articleConsultCount", articleConsultCount == null ? 0 : articleConsultCount);
            map.put("storeBrowseCount", storeBrowseCount == null ? 0 : storeBrowseCount);
            map.put("storeShareCount", storeShareCount == null ? 0 : storeShareCount);
            map.put("storeConsultCount", storeConsultCount == null ? 0 : storeConsultCount);

            analysisDataList.add(map);
            map = null ;
            analyData = null ;
            lastCalendar.add(Calendar.DAY_OF_MONTH,1);
        }
        calendar = null ;
        calendar1 = null ;
        calendar2 = null ;
        lastCalendar = null ;
        calendar3 = null ;
        return analysisDataList ;
    }

    @RequestMapping(value = "/moreMessage.do", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public Object moreMessage(HttpServletRequest request, HttpServletResponse response){
    	String methodName = "moreMessage";
    	String dayRegion = request.getParameter("dayRegion");
        String dateMin = request.getParameter("dateMin");
        String dateMax = request.getParameter("dateMax");
        String pageNo = request.getParameter("page");
        String pageSize = request.getParameter("pageSize");
        StoreStatsDataCondition condition = new StoreStatsDataCondition();

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        condition.setSysCd(SplSystemConstant.SPL_SHOP_APP_CD);
        if(StringUtils.isEmpty(dayRegion) && StringUtils.isEmpty(dateMin)&&StringUtils.isEmpty(dateMax)){
        	dayRegion = "30";
        }
        if (StringUtils.isNotEmpty(dayRegion)) {
            if ("1".equals(dayRegion)) {
                calendar.add(Calendar.DAY_OF_MONTH, -1);
            } else if ("7".equals(dayRegion)) {
                calendar.add(Calendar.DAY_OF_MONTH, -7);
            } else if ("15".equals(dayRegion)) {
                calendar.add(Calendar.DAY_OF_MONTH, -15);
            } else if ("30".equals(dayRegion)) {
                calendar.add(Calendar.DAY_OF_MONTH, -30);
            }
            if ("1".equals(dayRegion)) {
            	condition.setActionDtMax(calendar.getTime());
            }else{
            	condition.setActionDtMax(new Date());
            }
            condition.setActionDtMin(calendar.getTime());
        } else {
            if (StringUtils.isEmpty(dateMin) && StringUtils.isEmpty(dateMax)) {
                calendar.add(Calendar.DAY_OF_MONTH, -1);
                condition.setActionDtMin(calendar.getTime());
                condition.setActionDtMax(new Date());
            }else{
                Date mindate = DateUtils.formatStringToDate(dateMin, DateUtils.YYYY_MM_DD);
                Date maxdate = DateUtils.formatStringToDate(dateMax, DateUtils.YYYY_MM_DD);
                condition.setActionDtMin(mindate);
                condition.setActionDtMax(maxdate);
            }
        }
        
        PaginationVo page = new PaginationVo();
        if(StringUtils.isNotEmpty(pageNo)){
        	page.setPageNo(Integer.parseInt(pageNo));
        }
        if(StringUtils.isNotEmpty(pageSize)){
        	page.setPageSize(Integer.parseInt(pageSize));
        }
        condition.setLiveType(StoreLiveTypCdNum.WELCOME.name());
        page.setCondition(condition);
		PaginationVo pager = this.storeStatsDataService.getStoreStatsListByPage(page,null);
		List<StoreStatsDataVO> datas = (List<StoreStatsDataVO>)pager.getDatas();
		ListPageVO<StoreStatsDataVO> listPageVO = new ListPageVO<>(datas,(int)pager.getTotalCount());
        BaseLogUtils.newWebLogger("返回页面数据为："+JSON.toJSONString(listPageVO)).setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();
    	return listPageVO ;
    }
    
    @RequestMapping(value = "/exportMoreMessages.do", method = {RequestMethod.GET, RequestMethod.POST})
    @ResponseBody
    public Object exportMoreMessages(HttpServletRequest request, HttpServletResponse response){
    	String methodName = "exportMoreMessages";
    	String dayRegion = request.getParameter("dayRegion");
        String dateMin = request.getParameter("dateMin");
        String dateMax = request.getParameter("dateMax");
        if(StringUtils.isEmpty(dayRegion) && StringUtils.isEmpty(dateMin)&&StringUtils.isEmpty(dateMax)){
        	dayRegion = "30";
        }
        StoreStatsDataCondition condition = new StoreStatsDataCondition();

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        condition.setSysCd(SplSystemConstant.SPL_SHOP_APP_CD);
        if (StringUtils.isNotEmpty(dayRegion) && !dayRegion.equals("0")) {
            if ("1".equals(dayRegion)) {
                calendar.add(Calendar.DAY_OF_MONTH, -1);
            } else if ("7".equals(dayRegion)) {
                calendar.add(Calendar.DAY_OF_MONTH, -7);
            } else if ("15".equals(dayRegion)) {
                calendar.add(Calendar.DAY_OF_MONTH, -15);
            } else if ("30".equals(dayRegion)) {
                calendar.add(Calendar.DAY_OF_MONTH, -30);
            }
            if ("1".equals(dayRegion)) {
            	condition.setActionDtMax(calendar.getTime());
            }else{
            	condition.setActionDtMax(new Date());
            }
            condition.setActionDtMin(calendar.getTime());
            
        } else {
            if (StringUtils.isEmpty(dateMin) && StringUtils.isEmpty(dateMax)) {
                calendar.add(Calendar.DAY_OF_MONTH, -1);
                condition.setActionDtMin(calendar.getTime());
                condition.setActionDtMax(new Date());
            }else{
                Date mindate = DateUtils.formatStringToDate(dateMin, DateUtils.YYYY_MM_DD);
                Date maxdate = DateUtils.formatStringToDate(dateMax, DateUtils.YYYY_MM_DD);
                condition.setActionDtMin(mindate);
                condition.setActionDtMax(maxdate);
            }
        }
        
        PaginationVo page = new PaginationVo();
        
        condition.setLiveType(StoreLiveTypCdNum.WELCOME.name());
        page.setCondition(condition);
		PaginationVo pager = this.storeStatsDataService.getStoreStatsListByPage(page,"export" );
		List<StoreStatsDataVO> datas = (List<StoreStatsDataVO>)pager.getDatas();
		
		//导出数据
        ExportParams params = new ExportParams(null, null, ExcelType.XSSF);
		params.setTitleHeight((short) 5);
		params.setColor(HSSFColor.GREY_25_PERCENT.index);// 表头颜色
		params.setHeaderColor(HSSFColor.WHITE.index);
		Workbook workbook = (Workbook) ExcelExportUtil.exportExcel(params, StoreStatsDataVO.class,datas);
		String filePath = "moreMessages";
		String serverFilePath = this.getServerFilePath(filePath);
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		serverFilePath = serverFilePath + "数据统计" + sdf.format(new Date()) + ".xlsx";
		FileOutputStream fos = null;
        BaseLogUtils.newWebLogger("获取文件保存服务器路径.savePath:" + serverFilePath).setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();
		try {
			fos = new FileOutputStream(serverFilePath);
			workbook.write(fos);
			fos.flush();
		} catch (FileNotFoundException e) {
            BaseLogUtils.newWebLogger("导出数据统计失败,业务异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .warn(LogExceptionEnum.COMMON_CODE_0002);
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_700, e.getMessage());
		} catch (Exception e) {
            BaseLogUtils.newWebLogger("导出数据统计失败,系统异常").setLogOperType(LogOperEnum.REQ)
                    .setSysCd(CurrentThreadContext.getCurrentSysCd())
                    .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                    .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                    .setWarning(false)
                    .setThrowable(e)
                    .error(LogExceptionEnum.COMMON_CODE_0099);
			throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_700,
					BaseExceptionConstant.BASE_EXCEPTION_CODE_700_NAME);
		} finally {
			try {
				if (null != fos) {
					fos.close();
				}
			} catch (IOException e) {
                BaseLogUtils.newWebLogger("导出数据统计失败,系统异常").setLogOperType(LogOperEnum.REQ)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                        .setWarning(false)
                        .setThrowable(e)
                        .error(LogExceptionEnum.COMMON_CODE_0099);
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_700,
						BaseExceptionConstant.BASE_EXCEPTION_CODE_700_NAME);
			}
		}
		DataResultVO result = new DataResultVO();
		result.setSuccess(BaseConstant.IS_YESNO_YES);
		result.setInfo("导出成功");
		String serverPath = serverFilePath.replace(
				PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_ROOT_PATH),
				PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_SERVER_PATH));
		result.setData(serverPath);
    	return result ;
    }
    
    
    /**
	 * 创建文件服务器保存路径
	 */
	private String getServerFilePath(String filePath) throws BaseException {
		String prifixPath = PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.SYS_FILE_UPLOAD_ROOT_PATH);// 根目录
		StringBuffer savePath = new StringBuffer(prifixPath);// 最终保存路径
		if (!savePath.toString().endsWith(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH)) {// 判断是否以"/"结尾,不是加入斜杠
			savePath.append(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH);
		}
		savePath.append(PropertiesCacheUtils.getProperty(SysUlFilesRecConstant.UPLOAD_COSTOMER_PATH));// 自定义代码-其中包括系统代码
		if (StringUtils.isNotEmpty(filePath)) {// 如果不等于空则加入
			if (filePath.startsWith(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH)) {// 判断是否以"/"开头
				savePath.append(filePath.substring(1));
			} else {
				savePath.append(filePath);
			}

		}
		if (!savePath.toString().endsWith(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH)) {// 判断是否以"/"结尾
			savePath.append(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH);
		}
		String currentTime = DateUtils.formatDateToString(new Date(), DateUtils.YYYYMMDD);
		savePath.append(currentTime);
		savePath.append(SysUlFilesRecConstant.SYS_FILE_PATH_SLASH);
		// 检查目录
		File pathFile = new File(savePath.toString());
		 //File pathFile = new File("D:/excel/");
		if (!pathFile.exists()) {
			// 文件夹不存 创建文件
			boolean createPath = pathFile.mkdirs();
			if (!createPath) {
                BaseLogUtils.newWebLogger("创建文件保存服务器路径失败.savePath:" + savePath).setLogOperType(LogOperEnum.REQ)
                        .setSysCd(CurrentThreadContext.getCurrentSysCd())
                        .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                        .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                        .setWarning(false)
                        .warn(LogExceptionEnum.COMMON_CODE_0002);
				throw new BaseException(BaseExceptionConstant.BASE_EXCEPTION_CODE_600, "服务器附件目录未创建成功!");
			}
		}
        BaseLogUtils.newWebLogger("获取文件保存服务器路径.savePath:" + savePath).setLogOperType(LogOperEnum.REQ)
                .setSysCd(CurrentThreadContext.getCurrentSysCd())
                .setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
                .setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
                .setWarning(false)
                .info();
		return savePath.toString();
		// return "C:/home/";
	}
}